package logic

import (
	"context"
	"house/houseclient"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateUserLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUpdateUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateUserLogic {
	return &UpdateUserLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UpdateUserLogic) UpdateUser(req *types.UpdateUserRequest) (resp *types.Response, err error) {
	// todo:用户审核
	user, err := l.svcCtx.HouseRpc.UpdateUser(l.ctx, &houseclient.UpdateUserReq{
		Nick:        req.Nick,
		RealName:    req.RealName,
		IdCard:      req.IdCard,
		IdCardFrond: req.IdCardFrond,
		IdCardSide:  req.IdCardSide,
		Status:      req.Status,
		UserId:      req.UserId,
	})
	if err != nil {
		return &types.Response{
			Code: 500,
			Msg:  err.Error(),
			Data: nil,
		}, nil
	}
	return &types.Response{
		Code: 200,
		Msg:  "审核通过",
		Data: user,
	}, nil
}
